// main.cpp : Defines the entry point for the application.
//
// Artyom Bondar's
//
//  OBFUSCATED SORT 
//
// I decided to remove all #define statements, cuz it's not really fairplay, as i've read
// I didn't change the algorythm but delited all not-functional parts
// So enjoy the beautiful world of literature
//
//
//
#include <iostream>
template <class T>
void WhatAboutSomeNovellists(T * FranzKafka, int JohnFauls, bool IsUelsh){
    int GermanGesse=1, TomasMann, ChuckPalanik;int IrvinUelsh = 1;T * JanPoleSartre; // Sickness
    while (GermanGesse<JohnFauls){TomasMann=0;while (TomasMann<JohnFauls){ // This is a bat country. We can't stop here
	if (TomasMann+GermanGesse >= JohnFauls) break; // TomasMann != GermanGesse
	int Coupland = ChuckPalanik = (TomasMann+GermanGesse*2>JohnFauls) ? (JohnFauls-(TomasMann+GermanGesse)) : GermanGesse;
	IrvinUelsh= IsUelsh?GermanGesse:GermanGesse/2;T * JustPrust = (FranzKafka+TomasMann);T * WilliamBerrouse = JustPrust+GermanGesse;
	T* CharlesBykovsky = new T[IrvinUelsh+Coupland];int HunterTompson = 0; // bool IsUeslh - shows the way of doing algorythm
	while (IrvinUelsh && Coupland){if (*JustPrust < *WilliamBerrouse){
	CharlesBykovsky[HunterTompson] = *JustPrust;JustPrust++; IrvinUelsh--;}else {
	CharlesBykovsky[HunterTompson] = *WilliamBerrouse;WilliamBerrouse++; Coupland--;}HunterTompson++;
	}if (IrvinUelsh == 0){for (int i=0; i<Coupland; i++){CharlesBykovsky[HunterTompson++] = *WilliamBerrouse++;
	}}else {for (int i=0; i<IrvinUelsh; i++){CharlesBykovsky[HunterTompson++] = *JustPrust++;}}
	IsUelsh = (TomasMann+GermanGesse < JohnFauls);JanPoleSartre = CharlesBykovsky;
	for (int i=0; i<GermanGesse+ChuckPalanik; i++) FranzKafka[TomasMann+i] = JanPoleSartre[i];delete [] JanPoleSartre;TomasMann+=GermanGesse*2;
	}GermanGesse*=2;} // 1984.It can help
}
// or not
using namespace std;
int main(int argc, char* argv[])
{
	int a[] = { 9 , 7 , 3 , 1 , 2 , 12}; // Submit array for sorting there
	int len = 6;
	WhatAboutSomeNovellists<int>( a , 5 , true); // Also it sorts the "a" array
	for( int i = 0; i < len; ++i )
	{
		cout << a[i];
		cout << " ";
	}
	cout << "\n";
	return 0;
}